import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import unusedImports from 'eslint-plugin-unused-imports';
import vue from 'eslint-plugin-vue';
import vueParser from 'vue-eslint-parser';

export default [
  js.configs.recommended,
  ...vue.configs['flat/recommended'],
  {
    files: ['**/*.{js,ts,vue}'],
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        parser: typescriptParser,
        ecmaVersion: 'latest',
        sourceType: 'module',
        ecmaFeatures: {
          jsx: true,
        },
      },
      globals: {
        browser: true,
        es2021: true,
      },
    },
    plugins: {
      vue,
      '@typescript-eslint': typescript,
      prettier,
      'unused-imports': unusedImports,
    },
    rules: {
      'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
      'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
      'no-undef': 'off',
      'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
      'class-methods-use-this': 'off',
      'prefer-destructuring': 'off',
      'import/no-unresolved': 'off',
      'unused-imports/no-unused-imports': 'error',
      'no-underscore-dangle': 'off',
      'consistent-return': 'off',
      'func-names': 'off',
      'import/extensions': 'off',
      'import/prefer-default-export': 'off',
      'vue/no-setup-props-destructure': 'off',
      'vue/require-default-prop': 'off',
      'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
      '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
      '@typescript-eslint/no-inferrable-types': 'off',
      '@typescript-eslint/no-explicit-any': 'error',
      '@typescript-eslint/explicit-module-boundary-types': 'error',
      'no-param-reassign': 'off',
      'no-useless-constructor': 'off',
      'no-empty-function': 'off',
    },
  },
];
